<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="vue/vue.min.js"></script>
    <title>Document</title>
    <style>
    	ul{
    		margin: 0;
    		padding: 0;
    		list-style: none;
    		width: 100%;
    	}
        li {
        	padding-left: 30px;
            width: 100%;
            height: 50px;
            line-height: 50px; 
            border: 1px solid #ddd;
            background-color: aquamarine;
        }

        li:nth-of-type(2n-1) {
            background-color: azure;
            transition: 0.5s;
        }

        input[type="text"] {
            width: 260px;
            height: 30px;
            padding-left: 10px;
        }

        input[type="button"] {
            width: 50px;
            height: 34px;
            background-color: #38f;
            color: #fff;
        }
        
        .v-enter,.v-leave-to{
        	opacity: 0;
        	transform: translateY(50px);
        }
        .v-enter-active, .v-leave-active {
			transition: .5s;
		}
		
		
		.v-move{
			transition: .5s;
		}
		.v-leave-active {
			position: absolute;
		}
    </style>
</head>

<body>
    <div id="app">
        <label>
            id:
            <input type="text" v-model="id">
        </label>
        <label>
            name:
            <input type="text" v-model="name" @keyup.enter="add">
        </label>
        <label>
            <input type="button" value="添加" @click="add">
        </label>
    	<transition-group appear tag="ul">
    		<li v-for="(item,i) in list" :key="item.id" @click="del(i)">{{item.id}}--{{item.name}}</li>
    	</transition-group>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                id: '',
                name: '',
                list: [
                    { id: '001', name: '张三'},
                    { id: '002', name: '李四'},
                    { id: '003', name: '王五'},
                    { id: '004', name: '赵六'},
                    { id: '005', name: '麻子'},
                    { id: '006', name: '赵八'},
                    { id: '007', name: '王五'},
                    { id: '008', name: '赵六'}
                ]
            },
            methods: {
                add() {
                    this.list.push({ id: this.id, name: this.name, time: new Date() })
                },
                del(i){
                	this.list.splice(i,1);
                }
            },
        })
    </script>
</body>

</html>